import axios from 'axios'
import {message} from 'antd'

// create an axios instance
const service = axios.create({
  baseURL: process.env.REACT_APP_BASE_API + '/' + 'v1',
  timeout: 30000
})

// response interceptor
service.interceptors.response.use(
    res => {
      if (res.data.code !== 200) {
        if (res.data.code === 100 || res.data.code === 20000 || res.data.code === 20002) {
          message.error(res.data.msg)
        } else if (res.data.code === 11) {


        } else if (res.data.code === 10) {

        }

        return Promise.reject(res.data)
      } else {
        return res.data
      }
    },
    error => {
      return Promise.reject(error)
    }
);

export default service
